package com.songcha.module_test.ui.activity

import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable
import com.songcha.library_base.compose.BaseComposeActivity
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.material3.Button
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.foundation.border
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidView
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.songcha.library_common.ui.view.compose.ComposeAsyncImage
import com.songcha.library_common.util.GlideUtil

class TestActivity:BaseComposeActivity() {
    @Composable
    override fun ComposeRootView() {
        LazyColumn(
            modifier = Modifier.fillMaxSize()
                .background(Color.Red)
        ) {

            item {
                ItemImageView("https://calendar-songchayipin.oss-cn-guangzhou.aliyuncs.com/Applets/MBTI/MaskBackground/xinggeBG.png")
            }

            item {
                ItemImageView("https://calendar-songchayipin.oss-cn-guangzhou.aliyuncs.com/Applets/MBTI/MaskBackground/Group1.png")
            }

            item {
                ItemImageView("https://calendar-songchayipin.oss-cn-guangzhou.aliyuncs.com/Applets/MBTI/MaskBackground/Group2.png")
            }

            item {
                ItemImageView("https://calendar-songchayipin.oss-cn-guangzhou.aliyuncs.com/Applets/MBTI/MaskBackground/Group3.png")
            }

            item {
                ItemImageView("https://calendar-songchayipin.oss-cn-guangzhou.aliyuncs.com/Applets/MBTI/MaskBackground/Group4.png")
            }

            item {
                ItemImageView("https://calendar-songchayipin.oss-cn-guangzhou.aliyuncs.com/Applets/MBTI/MaskBackground/Group5.png")
            }

            item {
                ItemImageView("https://calendar-songchayipin.oss-cn-guangzhou.aliyuncs.com/Applets/MBTI/answer/leidaBG.png")
            }

            item {
                ItemImageView("https://calendar-songchayipin.oss-cn-guangzhou.aliyuncs.com/Applets/MBTI/analysiImg/INTJ/1.png")
            }

            item {
                ItemImageView("https://calendar-songchayipin.oss-cn-guangzhou.aliyuncs.com/Applets/MBTI/analysiImg/INTP/1.png")
            }

            item {
                ItemImageView("https://calendar-songchayipin.oss-cn-guangzhou.aliyuncs.com/Applets/MBTI/analysiImg/ENTJ/1.png")
            }

            item {
                ItemImageView("https://calendar-songchayipin.oss-cn-guangzhou.aliyuncs.com/Applets/MBTI/analysiImg/ENTP/1.png")
            }

        }
    }

    @Composable
    private fun ItemImageView(url:String){
        AndroidView(
                  modifier = Modifier.fillMaxWidth(),
                  factory = {ctx->
                  val iv = ImageView(ctx)
                  GlideUtil.loadNetImage(iv,url, DiskCacheStrategy.NONE)
                  iv
              })

        /*ComposeAsyncImage(
            modifier = Modifier.padding(bottom = 20.dp)
                .fillMaxWidth(),
            url = url
        )*/
    }
}